/**
 * Created with JetBrains PhpStorm.
 * User: ishowshao
 * Date: 13-4-22
 */
define(function () {
    var Matrix = function () {
        this._matrix = [];
    };
    Matrix.prototype.fromArray = function (array) {
        this._matrix = [];
        for (var i = 0; i < array.length; i++) {
            var row = [];
            for (var j = 0; j < array[i].length; j++) {
                row.push(array[i][j]);
            }
            this._matrix.push(row);
        }
        return this;
    };
    Matrix.prototype.init = function (x, y) {
        this._matrix = [];
        for (var i = 0; i < y; i++) {
            var row = [];
            for (var j = 0; j < x; j++) {
                row.push(0);
            }
            this._matrix.push(row);
        }
    };
    /**
     * 获取行列数
     * @return {Object}
     */
    Matrix.prototype.getSize = function () {
        return {
            x: this._matrix[0].length,
            y: this._matrix.length
        };
    };
    /**
     * 获取x,y位置的值
     * @param {Number} x
     * @param {Number} y
     * @return {Number}
     */
    Matrix.prototype.getXY = function (x, y) {
        return this._matrix[x][y];
    };
    Matrix.prototype.dump = function () {
        console.log(this._matrix);
        return this;
    };
    Matrix.add = function (ma, mb) {

    };
    return Matrix;
});
